//
//  VVSportMapModeController.m
//  DingDingSport
//
//  Created by 王惠平 on 2017/4/25.
//  Copyright © 2017年 will wang. All rights reserved.
//

#import "VVSportMapModeController.h"

@interface VVSportMapModeController ()

@property (nonatomic, copy) void(^selectBlock)(VVMapType mapType);


@property (strong, nonatomic) IBOutletCollection(UIButton) NSArray *mapModeBtns;


@end

@implementation VVSportMapModeController

- (instancetype)initWithSelectBlock:(void (^)(VVMapType))selectBlock {
    
    self = [super init];
    
    if (self) {
        
        self.selectBlock = selectBlock;
        
    }
    
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    //设置当前的地图类型
    UIButton *btn = self.mapModeBtns[self.mapType];
    
    btn.selected = YES;
    
}

- (IBAction)clickMapModeBtn:(UIButton *)sender {
    
    for (UIButton *btn in self.mapModeBtns) {
        
        if (!sender.selected) {
            
            //执行选中的block
            if (self.selectBlock) {
                
                self.selectBlock(sender.tag);
            }
            
        }
        
        //设置选中
        btn.selected = (btn == sender) ? YES : NO;


    }
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
